(function(window){
    // 定义了一个构造函数，该构造函数接收执行器函数(executor)
    function Promise(executor){
        // 增加实例属性state，初始值为pending
        this.state="pending";
        // 增加实例属性result,初始值为undefined
        this.result = undefined;
        try{
            executor(function(value){
                // 将当前的状态更改为fulfilled,值为接收的value
                this.state = "fulfilled";
                this.result = value;
            }.bind(this),function(value){
                // 将当前的状态更改为rejected,值为接收的value
                this.state = "rejected";
                this.result = value;
            }.bind(this));
        }catch(err){
            this.state = "rejected";
            this.result = err;
        }
        
        
    }
    window.Promise = Promise;
})(window);